<template>
	<!--找活 发布下架 -->
	<view class="upload">
 <u-tabs :list="tabs" name="cate_name" active-color="red" :is-scroll="false" :current="activeTab" @change="change"></u-tabs>
		<view class="" v-if="activeTab===0">
			<view class="box1" v-for="(item,index) in lookLive" :key='index'>
				<view class="box1_top">
					<view class="" style="display: flex;flex-wrap: wrap;">
						<text style="font-size: 28rpx;color: #007AFF;"><text style="background-color: red;color: #FFFFFF;padding: 4rpx 15rpx;margin-right: 15rpx;">招聘</text>{{item.work_type_name}}</text>
					</view>
					<view class="" style="display: flex;">
						<text v-for="(item,index) in item.work_list" :key='index' class="text_text">{{item}}</text>
					</view>
					<text style="font-size: 28rpx;color: #808080;">招聘人数：{{item.city_name}} |  {{item.number}}人</text>
					<view class="" style="display: flex;margin-top: 10rpx;">
						<text style="font-size: 28rpx;color: #808080;">发布时间：<text
								style="font-size: 28rpx;color: #F0AD4E;">{{item.data}}</text></text>
					</view>
				</view>
				<view class="box1_bottom">
					<text style="color: #007AFF;font-size: 28rpx;" @click="down(index)">下架招工</text>
				</view>
			</view>
			
			<image v-if="lookLive.length<1"  style="position: absolute;top:0;left: 0;bottom: 0;right: 0;margin: auto;width: 600rpx;" src="../../../static/image/no-data.png" mode=""></image>
		</view>

		<view class="" v-if="activeTab===1">
			<view class="box1" v-for="(item,index) in downLive" :key='index'>
				<view class="box1_top">
					<view class="" style="display: flex;">
						<text style="font-size: 28rpx;color: #007AFF;"><text style="background-color: red;color: #FFFFFF;padding: 4rpx 15rpx;margin-right: 15rpx;">招聘</text>{{item.work_type_name}}</text>
					</view>
					<view class="" style="display: flex;">
						<text v-for="(item,index) in item.work_list" :key='index' class="text_text">{{item}}</text>
					</view>
					<text style="font-size: 28rpx;color: #808080;margin-top: 10rpx;">招聘人数：{{item.city_name}} |  {{item.number}}人</text>
					<view class="" style="display: flex;margin-top: 10rpx;">
						<text style="font-size: 28rpx;color: #808080;">发布时间：<text
								style="font-size: 28rpx;color: #F0AD4E;">{{item.data}}</text></text>
					</view>
				</view>
				<view class="box1_bottom">
					<text style="color: #007AFF;font-size: 28rpx;" @click="newup(index)">重新发布</text>
				</view>
			</view>
			<image v-if="downLive.length<1"  style="position: absolute;top:0;left: 0;bottom: 0;right: 0;margin: auto;width: 600rpx;" src="../../../static/image/no-data.png" mode=""></image>
			
		</view>
	</view>
</template>

<script>
	import uniTabs from '@/components/v-tabs/v-tabs.vue'
	import api from '@/static/js/api.js'
	export default {
		components: {
			uniTabs
		},

		data() {
			return {
			tabs: [{name:'已发布'},
				{name:'已下架'},
				
			],
				activeTab: 0,
				num: 2,
				num2: 3,
				status: 0,
				statusText: '草稿',
				userinfo: '',
				lookLive: [],
				downLive:[]
			}
		},
		
		onShow() {
			this.userinfo = JSON.parse(uni.getStorageSync('userInfo'));
			this.activeTab = uni.getStorageSync('index')
			this.releaseLive()
			this.downList()
		},
		
		methods: {
			change(index) {
				this.activeTab = index
				if(this.activeTab==0){
					this.releaseLive()
				}else{
					this.downList()
				}
			},
			releaseLive() {
				let domain = "["+"('user_id', '=',"+this.userinfo.uid+"),('in_from_sale', '=', True)]"
				api.releaseLive('jhj.recruitment.release', '_api_page_list', this.userinfo.access_token, this
					.userinfo.uid, this.userinfo.uid, this.userinfo.partner_id, domain, 1000, 1).then(res => {
					this.lookLive = res.data
				}).catch(e => {
					uni.showToast({
						icon: 'none',
						title: e.message
					})
				})


			},
			//下架
			down(index) {
				api.downLive('jhj.recruitment.release', '_api_in_from_sale',this.userinfo.access_token, this.lookLive[index].id, false).then(res => {
					this.releaseLive()
					this.downList()
				}).catch(e => {
					uni.showToast({
						icon: 'none',
						title: e.message
					})
				})
			},
			//下架列表
			 downList(){
				 let domain = "["+"('user_id', '=',"+this.userinfo.uid+"),('in_from_sale', '=', False)]"
				 api.releaseLive('jhj.recruitment.release', '_api_page_list', this.userinfo.access_token, this
				 	.userinfo.uid, this.userinfo.uid, this.userinfo.partner_id, domain, 1000, 1).then(res => {
				 	this.downLive = res.data
				 }).catch(e => {
				 	uni.showToast({
				 		icon: 'none',
				 		title: e.message
				 	})
				 })
			 },
			 //上架
           newup(index) {
			   console.log(this.downLive[index].id)
				api.downLive('jhj.recruitment.release', '_api_in_from_sale',this.userinfo.access_token, this.downLive[index].id, true).then(res => {
					this.releaseLive()
					this.downList()
				}).catch(e => {
					uni.showToast({
						icon: 'none',
						title: e.message
					})
				})
			},
		}

	}
</script>

<style lang="less" scoped>
	.upload {
		width: 100%;
		height: 100vh;
		background-color: #EBEEF5;
	}

	.tabs {
		position: relative;
	}

	/deep/ .v-tabs {
		width: 100%;
		height: 100rpx;
		background-color: #FFFFFF;
		line-height: 100rpx;
	}

	/deep/ .v-tabs__container-item {
		width: 50%;
		justify-content: center;
	}

	.fixed {
		position: absolute;
		top: 2%;
		left: 30%;
		z-index: 99999;
		color: #DD524D;
	}

	.tfixed {
		position: absolute;
		top: 2%;
		right: 10%;
		z-index: 99999;
		color: #DD524D;
	}

	.checkfixed {
		position: absolute;
		top: 2%;
		left: 30%;
		z-index: 99999;
	}

	.tcheckfixed {
		position: absolute;
		top: 2%;
		right: 10%;
		z-index: 99999;
	}

	.box1 {

		margin-top: 10rpx;
		background-color: #FFFFFF;

		.box1_top {
			padding: 20rpx 60rpx 0 60rpx;
		}

		.text_text {
			padding: 4rpx 15rpx;
			background-color: #007AFF;
			font-size: 24rpx;
			color: #FFFFFF;
			margin-left: 30rpx;
			margin-top: 10rpx;
		}
        .text_text:nth-child(1) {
			margin-left: 0rpx;
		}

		.box1_bottom {
			margin-top: 10rpx;
			display: flex;
			justify-content: flex-end;

			text {
				width: 33%;
				text-align: center;
				display: inline-block;
				border: 1rpx solid #EEEEEE;
				padding: 10rpx 0;
				font-size: 28rpx;
			}

			.check {
				color: #999999;
			}

			.checkdv {
				color: #007AFF
			}

		}
	}
</style>
